//
//  StagesViewController.m
//  NewGame
//
//  Created by wwj on 15/9/24.
//  Copyright © 2015年 wwj. All rights reserved.
//

#import "StagesViewController.h"
#import "ReadyViewController.h"
#import "StageScrollerView.h"

@interface StagesViewController ()<UIScrollViewDelegate>
@property (weak ,nonatomic) IBOutlet StageScrollerView *scrollerView;

@property (weak ,nonatomic) IBOutlet UIPageControl *pageControl;
@end

@implementation StagesViewController

- (void)viewDidLoad {
    [super viewDidLoad];
 
    _scrollerView.itemClickBlock = ^(StageModel *model){
        [self performSegueWithIdentifier:@"ready" sender:model];
    };
}

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    ReadyViewController *readyVC = segue.destinationViewController;
    readyVC.stageModel = sender;
}

- (IBAction)back:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    int currentPage = scrollView.contentOffset.x / self.view.frame.size.width;
    _pageControl.currentPage = currentPage;
}

-(void)reloadDataWithNO:(int)number{
    [_scrollerView reloadDataWithNO:number];
}
@end
